/**
 * Cajax-jQuery Integration via jQuery.xhr plugin
 * @author aflesler
 */
 
;(function($) {

	$.xhr.register('cajax', function(settings) {
		if (isCrossDomain(settings.url))
			return new Cajax();
		return $.xhr.registry.xhr(settings);
	});
	
	function isCrossDomain(url) {
		return url.indexOf('://') !== -1 && getDomain(url) !== location.host;
	};
	
	function getDomain(url) {
		// Includes the port if available
		return url.split('/')[2];
	};

})(jQuery);